<?php
/**
*  +----------------------------------------------------------------------
*  | 文件功能：ContentSimpleModel.php：内容简略信息模型
*  +----------------------------------------------------------------------
*  | Copyright (c) 2022~2024 https://www.huihuiv.com All rights reserved. 
*  +----------------------------------------------------------------------
*  | Create At: 2024年03月13日 18:44:45
*  +----------------------------------------------------------------------
*  | Author: 半壶水 <star@cqshanwen.com>
*  +----------------------------------------------------------------------
*/
namespace App\Models;


class ContentSimpleModel extends BaseModel
{
    // 表名
    protected $table = 'sw_content_simple';

    // 主键
    protected $primaryKey = 'cs_id';

    // 允许写入字段
    protected $fillable = [
        'status',
        'cid',
        'type',
        'title',
        'description',
        'thumbnail',
        'like',
        'click',
        'author',
        'is_banner',
        'is_recommend'
    ];

    // 自动完成字段
    protected $attributes = [
        'status' => 0
    ];

    // 关联内容详情模型
    public function content_detail()
    {
        return $this->hasMany(ContentDetailModel::class, 'cs_id', 'cs_id');
    }

    // 关联用户表
    public function user()
    {
        return $this->hasMany(User::class, 'uid', 'author');
    }

    // 关联栏目模型
    public function category()
    {
        return $this->hasMany(CategoryModel::class, 'cid', 'cid');
    }
}
